<html>
<head></head>
<body>
<form action="" id="form-login">
    <div>
        <input type="text" name="username" id="username" placeholder="请输入用户名">
    </div>
    <div>
        <input type="password" name="password" id="password" placeholder="请输入密码">
    </div>
    <div>
        <input type="submit" value="立即登录">
    </div>
</form>
</body>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script>
    jQuery(function() {
        jQuery('#form-login').submit(function() {
            var params = {
                username: jQuery('#username').val(),
                password: jQuery('#password').val()
            }
            console.log(params)
            jQuery.post('/index.php?c=user&a=doLogin', params, function (response) {
                console.log(response)
                if (response.code == 0) {
                    alert(response.msg)
                } else {
                    window.location.href = '/index.php?c=center&a=index'
                }
            }, 'json')

            return false;
        })
    })
</script>
</html>